using SG;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem.LowLevel;

public class LogicManager : MonoBehaviour
{
    static LogicManager m_Instance;
    public static LogicManager Instance()
    {
        if (m_Instance == null)
        {
            m_Instance = InstanceHelper.Singleton<LogicManager>();
        }
        return m_Instance;
    }
    LogicBase m_CurLogic;

    private void Start()
    {
        
    }

    public void DoEnterGame()
    {
        SceneMgr.Instance().EditMode = false;
        SetCurLogic(LogicGame.Instance());
    }
    public void DoEnterEditor()
    {
        SceneMgr.Instance().EditMode = true;
        SetCurLogic(LogicEditMap.Instance());
    }

    public void DoClose()
    {
        SetCurLogic(null);
    }
    public void SetCurLogic(LogicBase curLogic)
    {

        if( m_CurLogic != null )
        {
            m_CurLogic.DoRelease();
        }
        m_CurLogic = curLogic;
    }
    public LogicBase GetCurLogic()
    {
        return m_CurLogic;

    }

    private void Update()
    {
        if( GetCurLogic() )
            GetCurLogic().DoUpdate();
    }
}
